package br.usp.icmc.lasdpc.gem.com;

import java.io.IOException;

import br.usp.icmc.lasdpc.gem.com.Message;

/**
 * Base protocol interface to be implemented in the classes that will use the
 * `comm' package.
 * <p>
 * In a minimalistic view, the objec should send and receive messages, and 
 * starts and stops its service. So, this is the foundation methods for this 
 * Interface no matter if using IP, TCP, ICMP, and others.
 * 
 * @author Lourenco Alves
 *
 */
public interface CommunicationPI {

	/** 
	 * Start a new socket and assign it to receive messages.
	 * @throws IOException
	 */
	public abstract void start() throws IOException;
	
	/**
	 * Close the socket and consequently, no messages are received.
	 */
	public abstract void stop();
	
	/**
	 * Send a message to destination pointed inside the message.
	 * @param message
	 * @see br.usp.icmc.lasdpc.gem.com.Message
	 */
	public abstract void send(Message message);

	/**
	 * Get a message from the network.
	 * @return the message read from the network
	 */
	public abstract Message receive();
	
}
